package mx.netbrain.controller;

import java.util.ArrayList;
import java.util.List;

import mx.netbrain.dao.GroupUserDao;
import mx.netbrain.dao.impl.GroupUserDaoImpl;
import mx.netbrain.model.Groups;
import mx.netbrain.model.Repositories;

public class GroupsController {

	public static boolean validateGroup(Groups groups, Repositories repository) {
		List<Long> listUserGroup = new ArrayList<Long>();
		GroupUserDao groupUserDao = new GroupUserDaoImpl();
		listUserGroup = groupUserDao.findUserForGroup(groups);
		if (listUserGroup.size() > 0) {
			if (RepositoriesController.validateRepository(listUserGroup,
					repository)) {
				return true;
			} else {
				return false;
			}
		} else {
			return true;
		}
	}

	public static List<Long> listUserForGroup(Groups groups) {
		List<Long> listUserGroup = new ArrayList<Long>();
		GroupUserDao groupUserDao = new GroupUserDaoImpl();
		listUserGroup = groupUserDao.findUserForGroup(groups);
		return listUserGroup;
	}

}
